package wifiunion.com.notice.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import java.util.ArrayList;
import java.util.List;

import wifiunion.com.notice.R;
import wifiunion.com.notice.entity.DeviceInList;

/**
 * Created by Administrator on 2016/11/23.
 */

public class AddNoticeDeviceAdapter extends RecyclerView.Adapter<NoticeDeviceViewHolder> {

    private Context mContext;

    private List<DeviceInList> data = new ArrayList<>();


//    private


    public AddNoticeDeviceAdapter(Context context, int type, List<DeviceInList> dt ) {
        mContext = context;
        mType = type;
        data = dt;
    }

    /**
     * 0 listview
     * 1 gridview
     */
    private int mType;

    @Override
    public NoticeDeviceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view;

         view = LayoutInflater.from(parent.getContext()).inflate(R.layout.notice_device_list_item, parent, false);


        NoticeDeviceViewHolder  cv = new NoticeDeviceViewHolder(view, mType);

        return cv;
    }

    @Override
    public void onBindViewHolder(NoticeDeviceViewHolder holder, int position) {


        DeviceInList device = data.get(position);
        if (mType == 0) {

            holder.mDevicenumtv.setText(device.getDeviceUnique());

            holder.mDevicemodeltv.setText(device.getDeviceName());

            holder.mDevicelistaddresstv.setText(device.getLocationName());




        }

    }

    @Override
    public int getItemCount() {
        return data.size();
    }
}
